#pragma once
#include <bondlib/BondContainer.h>
#include <bondlib/BondInfo.h>

#include <QPixmap>
#include <vector>

#pragma region Type definition

enum EnumCFEFSType {  // CFEFS成交类型
  em_cfets_best,      // 最优
  em_cfets_click,     // 点击成交
  em_cfets_xBond      // x-Bond
};
#pragma endregion
class STabCtrl;
class QStandardItem;
// TODO:某些函数移至BondLib？
namespace BondUtility {
void calcOptDate(const CBondInfo& bi, time_t& tm1, time_t& tm2);
void extractOptDate(const char* dateStr, std::vector<int>& dates);
QString FormatBidLimitTop(const QString& strBid);
void FormatWholeMktDealPrice(QString& strPrice, const char* cParam);
int getFirstIssueBondInfo(const char* cComBondKey);
int getBondDetailKlineBeginTime();
int GetInterestBeginTime(CBondInfo& bondInfo, int nReq);
int makeTypeOperate(int type, int operate);
void translateDonePrice(const QString& ctPrice, QString& strTemp);
bool isTransBond(const CBondInfo& info);
QString GetReqDataCombKey(const CBondInfo* pBondInfo);

bool updateBestPriceVersionByID(CBondContainer& container, const char* pComId,
                                int nMinver, int nMaxver, time_t nTime);
bool transfBestPriceToMarketStream(const xQBBestPriceUnit_c& best,
                                   xQBMarketStreamUnit_c& ms);
bool updateMarketStreamBySettlement(xQBMarketStreamUnit_c& ms, BYTE btSett,
                                    bool onlyCheck, bool bIsCfets);

void setCFETSCompany(int nType, const std::string& stName, QString& txt,
                     QString& tip);

QColor brokerColor(int brokerid);
STabCtrl* createBrokerTab(QWidget* parent, bool fixedSize = true,
                          bool hasMixedBroker = true);
void DisplayVolumn(const PRICE& varPrice, bool bValid, bool bExchange,
                   QStandardItem* item);
void DisplayCFETSVolumn(const CFETSQUOTE& varPrice, bool bBid,
                        QStandardItem* item);
void DisplayCFETSCompany(const CCFETSQuote::CFETSQUOTETYPE& cfets_quote_type,
                         const std::string& stName, QStandardItem* item);
void DisplayPriceNew(const PRICE& varPrice, bool bValid, QColor clrHLight,
                     bool bExchange, bool isTransBond, bool bFixedPrefix,
                     bool bTiny, bool checkSettlement, QStandardItem* item);
void SetUpdateTimeCol(QStandardItem* item, time_t tTime);
QString CheckStarBySettlement(const PRICE& varPrice, int& nStarFlag);
QString CheckStar(const PRICE& varPrice, int& nStarFlag);
QString getTakenCdcStr(const char* takenstr, const int nBondIndex,
                       bool bIsCDCAuthValid);
}  // namespace BondUtility
